package com.yidu.erp.service.hetonghch;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yidu.common.Pages;
import com.yidu.common.Tools;
import com.yidu.erp.dao.BeyondPactMapper;
import com.yidu.erp.model.BeyondAnnex;
import com.yidu.erp.model.BeyondDepartment;
import com.yidu.erp.model.BeyondPact;
import com.yidu.erp.service.hetonghch.PactService;


/**
 * @authorHuangChaoheng
 * @Dete2017年10月23日 上午9:47:25
 */
@Service
public class PactServiceImpl implements PactService{
	@Resource
	private BeyondPactMapper beyondPactMapper;

	@Override
	public int total() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public List<BeyondPact> list(Pages pages) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Map> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int insertSelective(BeyondPact record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int findAllRowCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKeySelective(BeyondPact beyondPacts) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public BeyondPact isExist(BeyondPact pact) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<BeyondPact> selectBeyondPact(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return beyondPactMapper.selectBeyondPact(map);
	}

	@Override
	public Map<String, Object> listPact(Map<String, Object> pact) {
		Map<String, Object> map = new HashMap<String, Object>();
		List<BeyondPact> list= beyondPactMapper.listPact(pact);
		System.out.println("集合为:            "+list);
		int rows=(int) beyondPactMapper.countRows(pact);
		System.out.println("行数:        "+rows);
		map.put("data",list);
		map.put("count",rows);
		map.put("code", 0);
		map.put("msg", 0);
		System.out.println("map为:         "+map.toString());
		return map;
	}

	@Override
	public BeyondPact pacteId(String pactId) {
		// TODO Auto-generated method stub
		return beyondPactMapper.selectByPrimaryKey(pactId);
	}

	/**
	 * 增加方法
	 */
	@Override
	public int addOrUpdate(BeyondPact pact) {
		int rows = 0;
		if(Tools.isEmpty(pact.getPactId())){
			Date date =new Date();
			pact.setPactSigntime(date);
			System.out.println("applyId为:     3dfgthyuh:    "+pact.getApplyId());
			rows = beyondPactMapper.insertSelective(pact);
		}else{
			rows = beyondPactMapper.updateByPrimaryKeySelective(pact);
		}
		return rows;
	}
	/**
	 * 删除方法
	 */

	@Override
	public int delete(String pactId) {
		
		return beyondPactMapper.deleteByPrimaryKey(pactId);
	}

	
}
